import { BaseEntity } from '../../base/entity/base';
import { Column, Entity, Index } from 'typeorm';

/**
 * 支付模块-用户余额表
 */
@Entity('pay_balance')
export class PayBalanceEntity extends BaseEntity {
  @Index({ unique: true })
  @Column({ comment: '用户ID' })
  userId: number;

  @Column({ 
    comment: '可用余额', 
    type: 'decimal', 
    precision: 10, 
    scale: 2, 
    default: 0 
  })
  availableBalance: number;

  @Column({ 
    comment: '冻结余额', 
    type: 'decimal', 
    precision: 10, 
    scale: 2, 
    default: 0 
  })
  frozenBalance: number;

  @Column({ 
    comment: '总余额', 
    type: 'decimal', 
    precision: 10, 
    scale: 2, 
    default: 0 
  })
  totalBalance: number;

  @Column({ comment: '最后更新时间' })
  lastUpdateTime: Date;

  @Column({ comment: '版本号(乐观锁)', default: 0 })
  version: number;

  @Column({ comment: '累计充值金额', type: 'decimal', precision: 10, scale: 2, default: 0 })
  totalRecharge: number;

  @Column({ comment: '累计消费金额', type: 'decimal', precision: 10, scale: 2, default: 0 })
  totalConsume: number;

  @Column({ comment: '余额状态', dict: ['正常', '冻结'], default: 0 })
  status: number;
}